<template>
  <div id="app">
    <ul v-for="(item,index) in arr" :key="index">
      <li>
        <span>{{item}}</span>
        <button @click="del(index)">删除</button>
      </li>
    </ul>
    <button @click="btn">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [1, 5, 3],
    };
  },
  methods: {
    btn(){
      const num=Math.floor(Math.random()*100)
      this.arr.push(num)
    },
    del(id){
      this.arr = this.arr.filter((item,indexs) => indexs !== id);
    }
  },
}
</script>